namespace ASPNET.StarterKit.IssueTracker
{
    using ASPNET.StarterKit.IssueTracker.BusinessLogicLayer;
    using System;
    using System.Diagnostics;
    using System.Runtime.CompilerServices;
    using System.Web.UI;
    using System.Web.UI.WebControls;

    public class CloneProject : Page
    {
        [AccessedThroughProperty("btnCancel")]
        private Button _btnCancel;
        [AccessedThroughProperty("btnClone")]
        private Button _btnClone;
        [AccessedThroughProperty("dropProjects")]
        private PickProject _dropProjects;
        [AccessedThroughProperty("lblError")]
        private Label _lblError;
        [AccessedThroughProperty("RequiredFieldValidator1")]
        private RequiredFieldValidator _RequiredFieldValidator1;
        [AccessedThroughProperty("txtNewProjectName")]
        private TextBox _txtNewProjectName;
        private object designerPlaceholderDeclaration;

        public CloneProject()
        {
            base.Load += new EventHandler(this.Page_Load);
            base.Init += new EventHandler(this.Page_Init);
        }

        public void CancelClone(object s, EventArgs e)
        {
            this.Response.Redirect("ProjectList.aspx");
        }

        public void CloneProjectMethod(object s, EventArgs e)
        {
            if (this.IsValid)
            {
                if (Project.CloneProject(this.dropProjects.SelectedValue, this.txtNewProjectName.Text))
                {
                    this.Response.Redirect("ProjectList.aspx");
                }
                else
                {
                    this.lblError.Text = "Could not clone project";
                }
            }
        }

        [DebuggerStepThrough]
        private void InitializeComponent()
        {
        }

        private void Page_Init(object sender, EventArgs e)
        {
            this.InitializeComponent();
        }

        private void Page_Load(object sender, EventArgs e)
        {
            if (!this.IsPostBack)
            {
                this.dropProjects.DataSource = Project.GetAllProjects();
                this.dropProjects.DataBind();
            }
        }

        protected virtual Button btnCancel
        {
            get
            {
                return this._btnCancel;
            }
            [MethodImpl(MethodImplOptions.Synchronized)]
            set
            {
                if (this._btnCancel != null)
                {
                    this._btnCancel.Click -= new EventHandler(this.CancelClone);
                }
                this._btnCancel = value;
                if (this._btnCancel != null)
                {
                    this._btnCancel.Click += new EventHandler(this.CancelClone);
                }
            }
        }

        protected virtual Button btnClone
        {
            get
            {
                return this._btnClone;
            }
            [MethodImpl(MethodImplOptions.Synchronized)]
            set
            {
                if (this._btnClone != null)
                {
                    this._btnClone.Click -= new EventHandler(this.CloneProjectMethod);
                }
                this._btnClone = value;
                if (this._btnClone != null)
                {
                    this._btnClone.Click += new EventHandler(this.CloneProjectMethod);
                }
            }
        }

        protected virtual PickProject dropProjects
        {
            get
            {
                return this._dropProjects;
            }
            [MethodImpl(MethodImplOptions.Synchronized)]
            set
            {
                if (this._dropProjects != null)
                {
                }
                this._dropProjects = value;
                if (this._dropProjects != null)
                {
                }
            }
        }

        protected virtual Label lblError
        {
            get
            {
                return this._lblError;
            }
            [MethodImpl(MethodImplOptions.Synchronized)]
            set
            {
                if (this._lblError != null)
                {
                }
                this._lblError = value;
                if (this._lblError != null)
                {
                }
            }
        }

        protected virtual RequiredFieldValidator RequiredFieldValidator1
        {
            get
            {
                return this._RequiredFieldValidator1;
            }
            [MethodImpl(MethodImplOptions.Synchronized)]
            set
            {
                if (this._RequiredFieldValidator1 != null)
                {
                }
                this._RequiredFieldValidator1 = value;
                if (this._RequiredFieldValidator1 != null)
                {
                }
            }
        }

        protected virtual TextBox txtNewProjectName
        {
            get
            {
                return this._txtNewProjectName;
            }
            [MethodImpl(MethodImplOptions.Synchronized)]
            set
            {
                if (this._txtNewProjectName != null)
                {
                }
                this._txtNewProjectName = value;
                if (this._txtNewProjectName != null)
                {
                }
            }
        }
    }
}

